<?php
$data = importData();
print_r($data);

function importData(){
    error_reporting(E_ALL); //开启错误
    set_time_limit(0); //脚本不超时
    include_once "./PHPExcel/PHPExcel.php";
    $filename="./worldcup.xlsx";
    $objReader = PHPExcel_IOFactory::createReaderForFile($filename);
    $objPHPExcel = $objReader->load($filename);

    $sheet = $objPHPExcel->getSheet(0); // 读取第一個工作表
    $highestRow = $sheet->getHighestDataRow();// 取得总行数
    $data=[];
    for($i=2;$i<=$highestRow;$i++){
        $thisLine=[];
        $thisLine['number'] =  $sheet->getCell('A'.$i)->getValue();
        $thisLine['match_date'] = gmdate("Y-m-d", PHPExcel_Shared_Date::ExcelToPHP($objPHPExcel->getActiveSheet()->getCell('B'.$i)->getValue()));
        $thisLine['match_time'] = gmdate("H:i", PHPExcel_Shared_Date::ExcelToPHP($objPHPExcel->getActiveSheet()->getCell('C'.$i)->getValue()));
        $teams = explode('-',$sheet->getCell('D'.$i)->getValue());
        $thisLine['team_a'] =  isset($teams[0])?$teams[0]:'';
        $thisLine['team_b'] =  isset($teams[1])?$teams[1]:'';
        $thisLine['create_time'] = date('Y-m-d H:i:s');
        $data[]=$thisLine;
    }
    return $data;
}
?>